package com.sfac.springBoot.module.account.service.impl;

import com.sfac.springBoot.module.account.dao.RoleDao;
import com.sfac.springBoot.module.account.pojo.Role;
import com.sfac.springBoot.module.account.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

/**
 * personal demo
 **/

@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    private RoleDao roleDao;

    @Override
    @Transactional
    public List<Role> selectRolesById(Integer id) {
        return Optional.ofNullable(roleDao.getRolesByUserId(id))
                .orElse(Collections.emptyList());
    }
}
